package ma.ensias.healthme.admin;

import java.util.ArrayList;

import ma.ensias.healthme.R;
import ma.ensias.healthme.entities.Personne;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
public class LazyAdapter extends BaseAdapter {
    
    private Activity activity;
    private ArrayList<Personne> data;
    private static LayoutInflater inflater=null;
    public ImageLoader imageLoader; 
    
    public LazyAdapter(Activity a, ArrayList<Personne> d) {
        activity = a;
        data=d;
        inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        imageLoader=new ImageLoader(activity.getApplicationContext());
    }

    public int getCount() {
        return data.size();
    }

    public Object getItem(int position) {
        return data.get(position);
    }

    public long getItemId(int position) {
        return position;
    }
    
    public View getView(int position, View convertView, ViewGroup parent) {
		View vi=convertView;
		if(convertView==null)
		 vi = inflater.inflate(R.layout.list_row, null);
		
		TextView nom_prenom = (TextView)vi.findViewById(R.id.nom_prenom); // title
		TextView fonction = (TextView)vi.findViewById(R.id.fonction); // artist name
		ImageView thumb_image=(ImageView)vi.findViewById(R.id.list_image); // thumb image
		
		Personne compte = new Personne();
		compte = data.get(position);
		nom_prenom.setText(compte.getNom()+" "+compte.getPrenom());
		fonction.setText(compte.getRole());
		
		return vi;
    }
}